<?php

/**
 * Cookie管理类
 */
class Cookie {

    public static function _get($name) {
        global $_SC;
        return $_COOKIE[$_SC['cookiepre'] . $name];
    }

    public static function _isset($name) {
        global $_SC;
        return isset($_COOKIE[$_SC['cookiepre'] . $name]);
    }

    public static function _set($name, $value, $expire=0, $path='', $domain='', $secure=0) {
        global $_SC;
        $path = $path ? $path : $_SC['cookiepath'];
        $domain = $domain ? $domain : (!$_SC['cookiedomain'] ? $_SC['cookiedomain'] : '');

        setcookie($_SC['cookiepre'] . $name, $value, $expire, $path, $domain, $secure);
    }

    public static function _clear() {
        global $_SC, $_SGLOBAL;
        foreach ($_COOKIE as $key => $value) {
            if (strpos($key, $_SC['cookiepre']) === 0) {
                setcookie($key, 0, $_SGLOBAL['timestamp'] - 3600, $_SC['cookiepath'], $_SC['cookiedomain']);
            }
        }
    }

}

?>
